package top.minuy.structure.linear.linked;
/**
 * @author Minuy
 * @time 16:08
 * @date 2021/8/23
 */
public class Test {
    public static void main(String[] args) {
        LinkedList<Integer> linkedList = new LinkedList<Integer>();

        for (int i=5;i>0;i--){
            linkedList.addFirst(i);
            System.out.println(linkedList);
        }

        linkedList.add(2,89);
        System.out.println(linkedList);


        linkedList.removeLast();
        System.out.println(linkedList);
        linkedList.removeFirst();
        System.out.println(linkedList);
        linkedList.remove(2);
        System.out.println(linkedList);

        System.out.println(linkedList.contains(89));
        System.out.println(linkedList.contains(819));

        System.out.println("------------------RecursiveLinkedList------------------");

        RecursiveLinkedList<Integer> recursiveLinkedList = new RecursiveLinkedList();

        recursiveLinkedList.add(0,1);
        recursiveLinkedList.add(0,2);
        recursiveLinkedList.add(0,3);
        recursiveLinkedList.add(0,4);
        recursiveLinkedList.add(2,9);
        System.out.println(recursiveLinkedList);

        recursiveLinkedList.remove(1);
        recursiveLinkedList.remove(2);

        System.out.println(recursiveLinkedList);
        System.out.println(recursiveLinkedList.get(2));
        recursiveLinkedList.set(2,999);
        System.out.println(recursiveLinkedList);

    }
}
